package omega

import "context"

type omegaCtxKey struct{}

type OmegaContext struct {
	GlobalTxId string
	LocalTxId  string
	ParentTxId string
}

func GetAllFromContext(ctx context.Context) (globalId string, localId string, ok bool) {
	omegaCtx, ok := ctx.Value(omegaCtxKey{}).(*OmegaContext)
	if !ok {
		return
	}
	globalId = omegaCtx.GlobalTxId
	localId = omegaCtx.LocalTxId
	return
}

func GetGlobalIdFromContext(ctx context.Context) (globalId string, ok bool) {
	omegaCtx, ok := ctx.Value(omegaCtxKey{}).(*OmegaContext)
	if !ok {
		return
	}
	globalId = omegaCtx.GlobalTxId
	return
}

func GetLocalIdFromContext(ctx context.Context) (localId string, ok bool) {
	omegaCtx, ok := ctx.Value(omegaCtxKey{}).(*OmegaContext)
	if !ok {
		return
	}
	localId = omegaCtx.LocalTxId
	return
}
